package com.niit.onlinemusicserver.controller;

import com.niit.onlinemusicserver.common.R;
import com.niit.onlinemusicserver.model.request.SongListRequest;
import com.niit.onlinemusicserver.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SongListController {

  @Autowired
  private SongListService songListService;

  // 返回所有歌单
  @GetMapping("/songList")
  public R allSongList() {
    return songListService.allSongList();
  }


  // 添加歌单
  @PostMapping("/songList/add")
  public R addSongList(@RequestBody SongListRequest addSongListRequest) {
    return songListService.addSongList(addSongListRequest);
  }

  // 更新歌单信息
  @PostMapping("/songList/update")
  public R updateSongListMsg(@RequestBody SongListRequest updateSongListRequest) {
    return songListService.updateSongListMsg(updateSongListRequest);
  }

  // 删除歌单
  @GetMapping("/songList/delete")
  public R deleteSongList(@RequestParam int id) {
    return songListService.deleteSongList(id);
  }


  // 返回指定类型的歌单
  @GetMapping("/songList/style/detail")
  public R songListOfStyle(@RequestParam String style) {
    return songListService.likeStyle('%' + style + '%');
  }
}
